<%@ page contentType="text/html; charset=utf-8" %>   
<%@ page import="java.io.*"%>   
<%@ page import="java.sql.*, javax.sql.*" %>   
<%@ page import="java.util.*"%>   
<%@ page import="java.math.*"%>   
<%   
String photo_no = request.getParameter("id");   
//mysql连接   
Class.forName("com.mysql.jdbc.Driver").newInstance();   
String URL="jdbc:mysql://localhost:3306/toursim?user=root&password=gaoxing311";   
Connection con = DriverManager.getConnection(URL);   
  
//oracle连接   
//String URL="jdbc:oracle:thin@localhost:1521:orcl2";   
//user="system";   
//password="manager";   
//Connection con = DriverManager.getConnection(URL,user,password);   
  
  
try{   
// 准备语句执行对象   
Statement stmt = con.createStatement();   
String sql = " SELECT * FROM senior WHERE id = "+ photo_no;   
ResultSet rs = stmt.executeQuery(sql);   
if (rs.next()) {   
Blob b = rs.getBlob("photo_image");   
long size = b.length();   
//out.print(size);   
byte[] bs = b.getBytes(1, (int)size);   
response.setContentType("image/jpeg");   
OutputStream outs = response.getOutputStream();   
outs.write(bs);   
outs.flush();   
rs.close();   
}   
else {   
rs.close();     
}   
}   
finally{   
con.close();   
}   
%>   